Skip to content

enhancement: consistent delete --all#678

Merged
avirtopeanu-ionos merged 4 commits into
masterfrom
enhancement/delete-all-consistent
Jul 23, 2026
Merged

enhancement: consistent delete --all#678
avirtopeanu-ionos merged 4 commits into
masterfrom
enhancement/delete-all-consistent

Conversation

@avirtopeanu-ionos

@avirtopeanu-ionos avirtopeanu-ionos commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Makes delete --all consistent across all resources.

New output style:

❯ i dc delete -a 
  5 datacenter(s) found to delete:
    - [NAME] (id: [UUID], location: [LOCATION])
    - [NAME] (id: [UUID], location: [LOCATION])
    - [NAME] (id: [UUID], location: [LOCATION])
    - [NAME] (id: [UUID], location: [LOCATION])
    - [NAME] (id: [UUID], location: [LOCATION])
  delete datacenter [NAME] (id: [UUID], location: [LOCATION])? [y/n]: y
✓ datacenter [UUID] deleted
  delete datacenter [NAME] (id: [UUID], location: [LOCATION])? [y/n]: y
✓ datacenter [UUID] deleted
  delete datacenter [NAME] (id: [UUID], location: [LOCATION])? [y/n]: n
  delete datacenter [NAME] (id: [UUID], location: [LOCATION])? [y/n]: n
  delete datacenter [NAME] (id: [UUID], location: [LOCATION])? [y/n]: y
  ✗ datacenter [UUID] — 403 - Access Denied: Lan [UUID] is delete-protected by 'VPN-[UUID]'.
  Done: 2 deleted, 2 skipped, 1 failed
  Error: 1 of 5 datacenter(s) could not be deleted

Copilot AI review requested due to automatic review settings June 23, 2026 10:54

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Introduces a shared implementation for delete --all to make bulk-deletion behavior consistent across ionosctl commands (preview, per-item confirmation with skip, continue-on-error, aggregated failure reporting), and migrates many existing resources to use it.

Changes:

  • Added internal/core.DeleteAll (generic) + DeleteAllError and shortAPIError helper, with unit tests.
  • Refactored many delete --all implementations across VPN, DBaaS, DNS, Container Registry, Monitoring/Logging, CDN, and CloudAPIv6 compute commands to use the shared flow.
  • Fixed specific command issues during refactor (e.g., Wireguard peer single-delete now returns API error; DBaaS mongo/mariadb --name flag corrected to string).

Reviewed changes

Copilot reviewed 64 out of 64 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
internal/core/delete_all.go New generic DeleteAll flow with preview/confirm/aggregate behavior and compact API error formatting
internal/core/delete_all_test.go Unit tests covering force, skip, aggregation, and API error shortening
commands/vpn/wireguard/peer/delete.go Uses shared DeleteAll; fixes single-delete to return API error; avoids nil endpoint deref in prompt
commands/vpn/wireguard/gateway/delete.go Refactors gateway --all deletion to shared DeleteAll
commands/vpn/ipsec/tunnel/delete.go Refactors tunnel --all deletion to shared DeleteAll
commands/vpn/ipsec/gateway/delete.go Refactors gateway --all deletion to shared DeleteAll
commands/vm-autoscaling/group/delete.go Refactors group --all deletion to shared DeleteAll
commands/object-storage/bucket/delete.go Refactors bucket --all deletion to shared DeleteAll
commands/monitoring/pipeline/delete.go Refactors pipeline --all deletion to shared DeleteAll; minor flag help cleanup
commands/logging-service/pipeline/delete.go Refactors pipeline --all deletion to shared DeleteAll; consolidates summary formatting
commands/kafka/topic/delete.go Refactors topic --all deletion to shared DeleteAll
commands/kafka/cluster/delete.go Refactors cluster --all deletion to shared DeleteAll
commands/dns/zone/delete.go Refactors zone --all deletion to shared DeleteAll with safer description formatting
commands/dns/secondary-zones/delete.go Refactors secondary zone --all deletion to shared DeleteAll
commands/dns/reverse-record/delete.go Refactors reverse record --all deletion to shared DeleteAll
commands/dns/record/delete.go Refactors record --all deletion to shared DeleteAll
commands/dbaas/postgres-v2/cluster/delete.go Refactors cluster --all deletion to shared DeleteAll while preserving state filter
commands/dbaas/mongo/user/delete.go Refactors user --all deletion to shared DeleteAll
commands/dbaas/mongo/cluster/delete.go Refactors cluster --all deletion to shared DeleteAll; fixes --name flag type
commands/dbaas/mariadb/cluster/delete.go Refactors cluster --all deletion to shared DeleteAll; fixes --name flag type
commands/dbaas/inmemorydb/replicaset/delete.go Refactors replicasets --all deletion to shared DeleteAll
commands/container-registry/token/delete.go Refactors token --all deletion to shared DeleteAll (single registry + across registries)
commands/container-registry/registry/delete.go Refactors registry --all deletion to shared DeleteAll
commands/compute/volume/run_volume.go Refactors volume --all deletion to shared DeleteAll with request-id verbose logging
commands/compute/user/user_test.go Removes unused test fixture
commands/compute/user/run_user.go Refactors users --all deletion and group-user removal --all to shared DeleteAll
commands/compute/user/run_s3key.go Refactors S3 key --all deletion to shared DeleteAll with request-id verbose logging
commands/compute/targetgroup/run_targetgroup.go Refactors target group --all deletion to shared DeleteAll with request-id verbose logging
commands/compute/snapshot/run_snapshot.go Refactors snapshot --all deletion to shared DeleteAll with request-id verbose logging
commands/compute/share/run_share.go Refactors share --all removal to shared DeleteAll with request-id verbose logging
commands/compute/server/run_server.go Refactors server --all deletion to shared DeleteAll with request-id verbose logging
commands/compute/pcc/run_pcc.go Refactors PCC --all deletion to shared DeleteAll with request-id verbose logging
commands/compute/nic/run_nic.go Refactors NIC --all deletion to shared DeleteAll with request-id verbose logging
commands/compute/networkloadbalancer/run_networkloadbalancer.go Refactors NLB --all deletion to shared DeleteAll with request-id verbose logging
commands/compute/networkloadbalancer/rule/run_networkloadbalancer_rule.go Refactors NLB rule --all deletion to shared DeleteAll with request-id verbose logging
commands/compute/networkloadbalancer/flowlog/run_networkloadbalancer_flowlog.go Refactors NLB flowlog --all deletion to shared DeleteAll with request-id verbose logging
commands/compute/natgateway/run_natgateway.go Refactors NAT gateway --all deletion to shared DeleteAll with request-id verbose logging
commands/compute/natgateway/rule/run_natgateway_rule.go Refactors NAT gateway rule --all deletion to shared DeleteAll with request-id verbose logging
commands/compute/natgateway/flowlog/run_natgateway_flowlog.go Refactors NAT gateway flowlog --all deletion to shared DeleteAll with request-id verbose logging
commands/compute/loadbalancer/run_loadbalancer.go Refactors load balancer --all deletion to shared DeleteAll with request-id verbose logging
commands/compute/lan/run_lan.go Refactors LAN --all deletion to shared DeleteAll with request-id verbose logging
commands/compute/k8s/nodepool/run_k8s_nodepool.go Refactors nodepool --all deletion to shared DeleteAll with request-id verbose logging
commands/compute/k8s/nodepool/k8s_nodepool_test.go Removes unused test fixtures
commands/compute/k8s/node/run_k8s_node.go Refactors k8s node --all deletion to shared DeleteAll with request-id verbose logging
commands/compute/k8s/cluster/run_k8s_cluster.go Refactors k8s cluster --all deletion to shared DeleteAll with request-id verbose logging
commands/compute/ipblock/run_ipblock.go Refactors IP block --all deletion to shared DeleteAll
commands/compute/image/run_image.go Refactors “delete all non-public images” to shared DeleteAll
commands/compute/group/run_group.go Refactors group --all deletion to shared DeleteAll with request-id verbose logging
commands/compute/flowlog/run_flowlog.go Refactors flowlog --all deletion to shared DeleteAll
commands/compute/flowlog/flowlog_test.go Removes unused test fixtures
commands/compute/firewallrule/run_firewallrule.go Refactors firewall rule --all deletion to shared DeleteAll with request-id verbose logging
commands/compute/firewallrule/firewallrule_test.go Cleans up unused imports/fixtures after refactor
commands/compute/datacenter/run_datacenter.go Refactors datacenter --all deletion to shared DeleteAll with request-id verbose logging
commands/compute/backupunit/run_backupunit.go Refactors backup unit --all deletion to shared DeleteAll with request-id verbose logging
commands/compute/backupunit/backupunit_test.go Removes unused fixtures after refactor
commands/compute/applicationloadbalancer/run_applicationloadbalancer.go Refactors ALB --all deletion to shared DeleteAll with request-id verbose logging
commands/compute/applicationloadbalancer/rule/run_applicationloadbalancer_rule.go Refactors ALB rule --all deletion to shared DeleteAll with request-id verbose logging
commands/compute/applicationloadbalancer/flowlog/run_applicationloadbalancer_flowlog.go Refactors ALB flowlog --all deletion to shared DeleteAll with request-id verbose logging
commands/compute/applicationloadbalancer/applicationloadbalancer_test.go Updates test expectation: deny confirmation skips instead of erroring
commands/cert/provider/delete.go Refactors provider --all deletion to shared DeleteAll; updates --all flag help text
commands/cert/certificate/delete.go Refactors certificate --all deletion to shared DeleteAll
commands/cert/autocertificate/delete.go Refactors autocertificate --all deletion to shared DeleteAll
commands/cdn/distribution/delete.go Refactors distribution --all deletion to shared DeleteAll
CHANGELOG.md Documents new consistent delete --all behavior and related fixes

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 99 to +102

if multiErr != nil {
return multiErr
}
// deleting public images is forbidden by the API, so only consider non-public ones
return getNonPublicImages(*allItems, c.Command.Command.ErrOrStderr())
},
@avirtopeanu-ionos
avirtopeanu-ionos force-pushed the enhancement/delete-all-consistent branch from 205eff7 to 4e96b8b Compare July 21, 2026 10:45
@sonarqubecloud

Copy link
Copy Markdown

@avirtopeanu-ionos
avirtopeanu-ionos requested review from a team, adeatcu-ionos, cavramoniu-ionos, cristiGuranIonos, mimihalescu and rmocanu-ionos and removed request for a team July 22, 2026 11:22
@avirtopeanu-ionos
avirtopeanu-ionos merged commit 0e4141a into master Jul 23, 2026
10 checks passed
@avirtopeanu-ionos
avirtopeanu-ionos deleted the enhancement/delete-all-consistent branch July 23, 2026 08:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants